package com.vint.lintcode;

import com.vint.common.ListNode;

/**
 * 排序链表删除重复元素, 简单
 */
public class Lintcode112 {
	public ListNode deleteDuplicates(ListNode head) {
		if (null == head || null == head.next) {
			return head;
		}
		ListNode visit = head.next;
		int basic = head.val;
		ListNode preNode = head;
		while (null != visit) {
			if (basic == visit.val) {
				preNode.next = visit.next;
			} else {
				preNode = visit;
				basic = visit.val;
			}
			visit = visit.next;
		}
		return head;
	}
}
